/*
 *    Copyright (c) 2018-2025, boss All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the boss developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: boss
 */

package com.hopes.bizz.risk.control.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hopes.bizz.risk.control.entity.RiskUnitEventEntity;
import com.hopes.bizz.risk.control.vo.RiskUnitEventVO;
import com.hopes.bizz.risk.parkgis.vo.OrgLevelVO;
import com.hopes.boss.admin.api.entity.SysDictItem;
import com.hopes.boss.common.data.datascope.BossBaseMapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 风险事件
 *
 * @author pig
 * @date 2023-07-19 16:17:44
 */
@Mapper
public interface RiskUnitEventMapper extends BossBaseMapper<RiskUnitEventEntity> {

    /**
     * 风险事件字典
     *
     * @return
     */
    List<SysDictItem> labelValueList();

    /**
     * 根据企业统计数量
     *
     * @return 统计结果
     */
    @MapKey("orgId")
    Map<Long, Long> countGroupByCompany();

    /**
     * 统计企业、风险等级
     *
     * @return 统计结果
     */
    List<OrgLevelVO> listGroupLevelCompany();


    /**
     * 根据Id 查询对象
     *
     * @param id 主键
     * @return 结果
     */
    RiskUnitEventVO getEventVoById(Long id);


    /**
     * 风险管控清单 查询
     *
     * @param riskUnitEventVO 查询条件
     * @return 结果集
     */
    List<RiskUnitEventEntity> queryForList(@Param("entity") RiskUnitEventVO riskUnitEventVO);

    /**
     * 分页查询
     *
     * @param page
     * @param entity
     * @return
     */
    Page<RiskUnitEventVO> selectPageVo(Page<RiskUnitEventVO> page, @Param("entity") RiskUnitEventEntity entity);

    RiskUnitEventVO getById(Serializable id);


    @Select("select * from risk_unit_event where uid = #{uid}")
    RiskUnitEventEntity getByUid(String uid);
}
